const _wr = function (type) {
  const orig = window.history[type];
  return function () {
    const rv = orig.apply(this, arguments);
    const e = new Event(type);
    e.arguments = arguments;
    window.dispatchEvent(e);
    return rv;
  };
};
window.history.pushState = _wr('pushState');
window.history.replaceState = _wr('replaceState');

window.$route = {
  push: function (url) {
    history.pushState(null, null, url);
  },
  replace: function (url) {
    history.replaceState(null, null, url)
  },
  goBack: function () {
    history.go(-1);
  }
}
